# 打卡记录时间计算，忘记打卡的留白


from contextlib import nullcontext
import openpyxl
import datetime

wb = openpyxl.load_workbook('人脸8月20220805.xlsx')
sh = wb['考勤记录汇总']
print(sh.max_column)
# print(list(sh.rows)[1][0].value)
for i in range(1,sh.max_row):
    print(list(sh.rows)[i][0].value,list(sh.rows)[i][6].value)
    kaoqing_time = list(sh.rows)[i][6].value
    try:
        date1 = kaoqing_time[:kaoqing_time.index(',')]
        date2 = kaoqing_time[kaoqing_time.rindex(',')+1:]
        print(date1,date2)
        d1 = datetime.datetime.strptime(date1, '%H:%M')
        d2 = datetime.datetime.strptime(date2, '%H:%M')
        print(d2-d1)
        sh.cell(i+1,8).value = d2-d1
    except Exception:
        sh.cell(i+1,8).value = ''
wb.save('人脸8月20220805.xlsx')
wb.close()
# print(wb.sheetnames)